<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.9.1"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Eigen-unsupported: Eigen::RandomSetter&lt; SparseMatrixType, MapTraits, OuterPacketBits &gt; Class Template Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
  $(document).ready(function() { init_search(); });
/* @license-end */
</script>
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    extensions: ["tex2jax.js", "TeX/AMSmath.js", "TeX/AMSsymbols.js"],
    jax: ["input/TeX","output/HTML-CSS"],
});
</script>
<script type="text/javascript" async="async" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="eigendoxy.css" rel="stylesheet" type="text/css">
<!--  -->
<script type="text/javascript" src="eigen_navtree_hacks.js"></script>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="Eigen_Silly_Professor_64x64.png"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname"><a href="http://eigen.tuxfamily.org">Eigen-unsupported</a>
   &#160;<span id="projectnumber">3.4.90 (git rev 67eeba6e720c5745abc77ae6c92ce0a44aa7b7ae)</span>
   </div>
  </td>
   <td>        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.svg"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.svg" alt=""/></a>
          </span>
        </div>
</td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.1 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search','.html');
/* @license-end */
</script>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('classEigen_1_1RandomSetter.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="classEigen_1_1RandomSetter-members.html">List of all members</a> &#124;
<a href="#pub-methods">Public Member Functions</a>  </div>
  <div class="headertitle">
<div class="title">Eigen::RandomSetter&lt; SparseMatrixType, MapTraits, OuterPacketBits &gt; Class Template Reference<div class="ingroups"><a class="el" href="group__SparseExtra__Module.html">SparseExtra module</a></div></div>  </div>
</div><!--header-->
<div class="contents">
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><h3>template&lt;typename SparseMatrixType, template&lt; typename T &gt; class MapTraits = StdUnorderedMapTraits, int OuterPacketBits = 6&gt;<br />
class Eigen::RandomSetter&lt; SparseMatrixType, MapTraits, OuterPacketBits &gt;</h3>

<p>The <a class="el" href="classEigen_1_1RandomSetter.html" title="The RandomSetter is a wrapper object allowing to set/update a sparse matrix with random access.">RandomSetter</a> is a wrapper object allowing to set/update a sparse matrix with random access. </p>
<dl class="tparams"><dt>Template Parameters</dt><dd>
  <table class="tparams">
    <tr><td class="paramname">SparseMatrixType</td><td>the type of the sparse matrix we are updating </td></tr>
    <tr><td class="paramname">MapTraits</td><td>a traits class representing the map implementation used for the temporary sparse storage. Its default value depends on the system. </td></tr>
    <tr><td class="paramname">OuterPacketBits</td><td>defines the number of rows (or columns) manage by a single map object as a power of two exponent.</td></tr>
  </table>
  </dd>
</dl>
<p>This class temporarily represents a sparse matrix object using a generic map implementation allowing for efficient random access. The conversion from the compressed representation to a hash_map object is performed in the <a class="el" href="classEigen_1_1RandomSetter.html" title="The RandomSetter is a wrapper object allowing to set/update a sparse matrix with random access.">RandomSetter</a> constructor, while the sparse matrix is updated back at destruction time. This strategy suggest the use of nested blocks as in this example:</p>
<div class="fragment"><div class="line">SparseMatrix&lt;double&gt; m(rows,cols);</div>
<div class="line">{</div>
<div class="line">  RandomSetter&lt;SparseMatrix&lt;double&gt; &gt; w(m);</div>
<div class="line">  <span class="comment">// don&#39;t use m but w instead with read/write random access to the coefficients:</span></div>
<div class="line">  <span class="keywordflow">for</span>(;;)</div>
<div class="line">    w(rand(),rand()) = rand;</div>
<div class="line">}</div>
<div class="line"><span class="comment">// when w is deleted, the data are copied back to m</span></div>
<div class="line"><span class="comment">// and m is ready to use.</span></div>
</div><!-- fragment --><p>Since hash_map objects are not fully sorted, representing a full matrix as a single hash_map would involve a big and costly sort to update the compressed matrix back. To overcome this issue, a <a class="el" href="classEigen_1_1RandomSetter.html" title="The RandomSetter is a wrapper object allowing to set/update a sparse matrix with random access.">RandomSetter</a> use multiple hash_map, each representing 2^OuterPacketBits columns or rows according to the storage order. To reach optimal performance, this value should be adjusted according to the average number of nonzeros per rows/columns.</p>
<p>The possible values for the template parameter MapTraits are:</p><ul>
<li><b><a class="el" href="structEigen_1_1StdMapTraits.html">StdMapTraits</a>:</b> corresponds to std::map. (does not perform very well)</li>
<li><b><a class="el" href="structEigen_1_1StdUnorderedMapTraits.html">StdUnorderedMapTraits</a>:</b> corresponds to std::unordered_map</li>
<li><b>GoogleDenseHashMapTraits:</b> corresponds to google::dense_hash_map (best efficiency, reasonable memory consumption)</li>
<li><b>GoogleSparseHashMapTraits:</b> corresponds to google::sparse_hash_map (best memory consumption, relatively good performance)</li>
</ul>
<p>The default map implementation depends on the availability, and the preferred order is: GoogleSparseHashMapTraits, <a class="el" href="structEigen_1_1StdUnorderedMapTraits.html">StdUnorderedMapTraits</a>, and finally <a class="el" href="structEigen_1_1StdMapTraits.html">StdMapTraits</a>.</p>
<p>For performance and memory consumption reasons it is highly recommended to use one of Google's hash_map implementations. To enable the support for them, you must define EIGEN_GOOGLEHASH_SUPPORT. This will include both &lt;google/dense_hash_map&gt; and &lt;google/sparse_hash_map&gt; for you.</p>
<dl class="section see"><dt>See also</dt><dd><a href="https://github.com/sparsehash/sparsehash">https://github.com/sparsehash/sparsehash</a> </dd></dl>
</div><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:ac34e5cd67e370641c3b48c8a91705046"><td class="memItemLeft" align="right" valign="top"><a class="elRef" href="../namespaceEigen.html#a62e77e0933482dafde8fe197d9a2cfde">Index</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classEigen_1_1RandomSetter.html#ac34e5cd67e370641c3b48c8a91705046">nonZeros</a> () const</td></tr>
<tr class="separator:ac34e5cd67e370641c3b48c8a91705046"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a77dcbbc964b42027e00af269a5147c68"><td class="memItemLeft" align="right" valign="top">Scalar &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classEigen_1_1RandomSetter.html#a77dcbbc964b42027e00af269a5147c68">operator()</a> (<a class="elRef" href="../namespaceEigen.html#a62e77e0933482dafde8fe197d9a2cfde">Index</a> row, <a class="elRef" href="../namespaceEigen.html#a62e77e0933482dafde8fe197d9a2cfde">Index</a> col)</td></tr>
<tr class="separator:a77dcbbc964b42027e00af269a5147c68"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a62e960bd52cec62a59ebb285f381138f"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classEigen_1_1RandomSetter.html#a62e960bd52cec62a59ebb285f381138f">RandomSetter</a> (SparseMatrixType &amp;target)</td></tr>
<tr class="separator:a62e960bd52cec62a59ebb285f381138f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a3e4a78672df59ab4dd2799919b431027"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classEigen_1_1RandomSetter.html#a3e4a78672df59ab4dd2799919b431027">~RandomSetter</a> ()</td></tr>
<tr class="separator:a3e4a78672df59ab4dd2799919b431027"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<h2 class="groupheader">Constructor &amp; Destructor Documentation</h2>
<a id="a62e960bd52cec62a59ebb285f381138f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a62e960bd52cec62a59ebb285f381138f">&#9670;&nbsp;</a></span>RandomSetter()</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename SparseMatrixType , template&lt; typename T &gt; class MapTraits = StdUnorderedMapTraits, int OuterPacketBits = 6&gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classEigen_1_1RandomSetter.html">Eigen::RandomSetter</a>&lt; SparseMatrixType, MapTraits, OuterPacketBits &gt;::<a class="el" href="classEigen_1_1RandomSetter.html">RandomSetter</a> </td>
          <td>(</td>
          <td class="paramtype">SparseMatrixType &amp;&#160;</td>
          <td class="paramname"><em>target</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>Constructs a random setter object from the sparse matrix <em>target</em> </p>
<p>Note that the initial value of <em>target</em> are imported. If you want to re-set a sparse matrix from scratch, then you must set it to zero first using the setZero() function. </p>

</div>
</div>
<a id="a3e4a78672df59ab4dd2799919b431027"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a3e4a78672df59ab4dd2799919b431027">&#9670;&nbsp;</a></span>~RandomSetter()</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename SparseMatrixType , template&lt; typename T &gt; class MapTraits = StdUnorderedMapTraits, int OuterPacketBits = 6&gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classEigen_1_1RandomSetter.html">Eigen::RandomSetter</a>&lt; SparseMatrixType, MapTraits, OuterPacketBits &gt;::~<a class="el" href="classEigen_1_1RandomSetter.html">RandomSetter</a> </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>Destructor updating back the sparse matrix target </p>

</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a id="ac34e5cd67e370641c3b48c8a91705046"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ac34e5cd67e370641c3b48c8a91705046">&#9670;&nbsp;</a></span>nonZeros()</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename SparseMatrixType , template&lt; typename T &gt; class MapTraits = StdUnorderedMapTraits, int OuterPacketBits = 6&gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="elRef" href="../namespaceEigen.html#a62e77e0933482dafde8fe197d9a2cfde">Index</a> <a class="el" href="classEigen_1_1RandomSetter.html">Eigen::RandomSetter</a>&lt; SparseMatrixType, MapTraits, OuterPacketBits &gt;::nonZeros </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<dl class="section return"><dt>Returns</dt><dd>the number of non zero coefficients</dd></dl>
<dl class="section note"><dt>Note</dt><dd>According to the underlying map/hash_map implementation, this function might be quite expensive. </dd></dl>

</div>
</div>
<a id="a77dcbbc964b42027e00af269a5147c68"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a77dcbbc964b42027e00af269a5147c68">&#9670;&nbsp;</a></span>operator()()</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename SparseMatrixType , template&lt; typename T &gt; class MapTraits = StdUnorderedMapTraits, int OuterPacketBits = 6&gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">Scalar&amp; <a class="el" href="classEigen_1_1RandomSetter.html">Eigen::RandomSetter</a>&lt; SparseMatrixType, MapTraits, OuterPacketBits &gt;::operator() </td>
          <td>(</td>
          <td class="paramtype"><a class="elRef" href="../namespaceEigen.html#a62e77e0933482dafde8fe197d9a2cfde">Index</a>&#160;</td>
          <td class="paramname"><em>row</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="elRef" href="../namespaceEigen.html#a62e77e0933482dafde8fe197d9a2cfde">Index</a>&#160;</td>
          <td class="paramname"><em>col</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<dl class="section return"><dt>Returns</dt><dd>a reference to the coefficient at given coordinates <em>row</em>, <em>col</em> </dd></dl>

</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li><a class="el" href="RandomSetter_8h_source.html">RandomSetter.h</a></li>
</ul>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="namespaceEigen.html">Eigen</a></li><li class="navelem"><a class="el" href="classEigen_1_1RandomSetter.html">RandomSetter</a></li>
    <li class="footer">Generated on Thu Apr 21 2022 13:08:00 for Eigen-unsupported by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.9.1 </li>
  </ul>
</div>
</body>
</html>
